package com.javaee.dao;


import com.javaee.entity.Student;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface StudentDao {

    @Insert("insert into t_manager_student (id, stu_name, from_place, parent_phone, current_grade, is_first, login_id, comment,status) values(#{id},#{stu_name},#{from_place},#{parent_phone},#{current_grade},#{is_first},#{login_id},#{comment},#{status})")
    public int add(Student student);

    @Insert("<script>"+
            "insert into t_manager_student (id, stu_name, from_place, parent_phone, current_grade, is_first, login_id, comment, status) values" +
            "<foreach collection='students' item='student' separator=','>"+
            "(#{student.id},#{student.stu_name},#{student.from_place},#{student.parent_phone},#{student.current_grade},#{student.is_first},#{student.login_id},#{student.comment},#{student.status})"+
            "</foreach>"+
            "</script>"
    )
    public int bulkAdd(@Param("students")List<Student> students);
    @Update("update t_manager_student set status = 1 WHERE id = 1")
    public int audit(int id);

    @Update(
            "<script>" +
            "UPDATE t_manager_student SET status = 1 WHERE id in"+
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>"+
            "#{id}"+
            "</foreach>"+
            "</script>"
    )
    public int bulkAudit(@Param("ids") List<Integer> ids);
}
